package main

import (
	"gin-vue-admin/server/core"
	"gin-vue-admin/server/global"
	"gin-vue-admin/server/initialize"
	"go.uber.org/zap"
)

//go:generate go env -w GO111MODULE=on
//go:generate go env -w GOPROXY=https://goproxy.cn,direct
//go:generate go mod tidy

// @title                       Swagger FileGroup API
// @version                     0.0.1
// @description                 This is a sample Server pets
// @securityDefinitions.apikey  ApiKeyAuth
// @in                          header
// @name                        x-token
// @BasePath                    /
func main() {
	global.Viper = core.Viper() // 初始化Viper
	initialize.BlackCache()
	global.Logger = core.Zap() // 初始化zap日志库
	zap.ReplaceGlobals(global.Logger)

	global.Db = initialize.Gorm() // gorm连接数据库

	if global.Db != nil {
		initialize.RegisterTables() // 初始化表
		initialize.TimerTask()      // 初识化定时任务
		// 程序结束前关闭数据库链接
		db, _ := global.Db.DB()
		defer db.Close()
	}
	core.RunServer()
}
